<?php
class filterModel extends baseModel{
    protected $table = 'filter';

    //选项列表
    public function filter_list($fid) {
        return $this->select('fid='.$fid,'','sequence asc,id asc');
    }

    //判断重复
    public function filter_info($cid,$urlname,$id=null) {
        if(!empty($id)){
            $where=' AND fid<>'.$id;
        }
        return $this->count('cid='.$cid.' AND urlname="'.$urlname.'"'.$where);
    }

    //选项信息
    public function info($id) {
        return $this->find('id='.$id);
    }

    //添加选项
    public function add($data)
    {

        return $this->insert($data);
    }
    //编辑选项
    public function edit($data)
    {
        $condition['id']=intval($data['id']);
        return $this->update($condition,$data); 
    }
    //删除选项
    public function del($id)
    {
        return $this->delete('id='.intval($id)); 
    }
    //通过FID删除
    public function list_del($fid)
    {
        model('filter_relation')->del_filter_relation($fid);
        return $this->delete('fid='.intval($fid));
    }

	
}